//
//  CZMainController.swift
//  微博08
//
//  Created by mac on 16/2/28.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class CZMainController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        addChildViewControllers()
        setValue(CZMainTabBar(), forKey: "tabBar")
    }
    
    func addChildViewControllers()
    {
        let homeVC = CZHomeController()
        addChildViewController(homeVC, title: "首页", imageName: "tabbar_home")
        
        
        let messageVC = CZMessageController()
        addChildViewController(messageVC, title: "消息", imageName: "tabbar_message_center")
        
        addChildViewController(UIViewController())
        
        
        let discoverVC = CZDiscoverController()
        addChildViewController(discoverVC, title: "发现", imageName: "tabbar_discover")
        
        
        let profileVC = CZProflieController()
        addChildViewController(profileVC, title: "我", imageName: "tabbar_profile")
    }

    func addChildViewController(controller: UIViewController,title: String,imageName: String)
    {
        controller.title = title
        controller.tabBarItem.image = UIImage(named: imageName)
        let selectedImage = imageName + "_highlighted"
        controller.tabBarItem.selectedImage = UIImage(named:selectedImage)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        controller.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.orangeColor()], forState: UIControlState.Selected)
        
        addChildViewController(UINavigationController(rootViewController: controller))
    }
    
    
    

}
